﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Shsc.Net.Common.Resource;
using Shsc.Net.Common;
using System.Web.Mvc;

namespace Shsc.Net.Web.Extension.Html
{
    public static class LocalizationHelpers
    {
        public static string Lang(this HtmlHelper htmlhelper, string key)
        {            
            string language = htmlhelper.ViewContext.HttpContext.Request.ServerVariables["Http_Accept_Language"];
            if (language.IndexOf(",") > 0)
            {
                language = language.Substring(0, language.IndexOf(","));
            }
            return MessageUtil.getLabel(key, language, Constants.LabelResourcePath);
        } 
    }
}
